﻿using MoetutuTranslate.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace MoetutuTranslate.ScannerHelper
{
    class GetTagCount
    {
        public static int GetCount(String Tag) {
            string Shtml = WebHelper.HttpGet("https://www.pixiv.net/search.php?s_mode=s_tag_full&word=" + HtmlHelper.CodingToUTF8(Tag));
         
            int count = 0;
            foreach (string line in HtmlHelper.GetTextValueList(Shtml, "//span[@class='count-badge']")) {
            
                try { count = Convert.ToInt32(Regex.Match(line, "[0-9]{1,}").Value); } catch (Exception ex) { PrintLog.Log(ex); }
            }
            Console.WriteLine("获取{0}数量{1}",Tag,count);
            return count;
        }
    }
}
